<script type="text/javascript">
	function doSearchLinkage(value) {
		
	}
	
	//表格查询  
	function reloadLinkageTime() {
		var params = linkage_time_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		linkage_time_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		linkage_time_list.datagrid('unselectAll');
		linkage_time_list.datagrid('uncheckAll');
	}


	function addLinkage() {
		createFromWindow("新增信息", "linkage.do?editLinkage", "linkage.do?saveLinkage",
				function(data) {
					reloadLinkageTime();
				});
	}
	
	function deleteLinkage() {
		var rows = linkage_time_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('linkage.do?deleteLinkageItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadLinkageTime();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function editLinkage() {
		var rows = linkage_time_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("编辑信息", "linkage.do?editLinkage&linkageId=" + rows[0].id,
					"linkage.do?saveLinkage", function(data) {
						reloadLinkageTime();
					},true);
		} else {
			showMsg('请选择操作记录.');
		}

	}
	
	
	//操作按钮触发
	function operationsLookLinkage(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = linkage_time_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("查看信息", "linkage.do?editLinkage&linkageId=" + id,
					null, null,false);
		} else {
			showMsg('请选择查看记录.');
		}
	}
	
	function operationsEditLinkage(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = linkage_time_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("编辑信息", "linkage.do?editLinkage&linkageId=" + id,
					"linkage.do?saveLinkage", function(data) {
						reloadLinkageTime();
					},true);
		} else {
			showMsg('请选择编辑记录.');
		}
	}
	
	function operationsSendLinkage() {
		printLog('发送');
	}
	
	function operationsDeleteLinkage(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = new_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			$.messager.confirm('询问', '你确认要删除吗?', function(r) {
				if (r) {
					$.post('linkage.do?deleteLinkageItems', {
						ids : id
					}, function(result) {
						if (result.success) {
							reloadLinkageTime(); 
						}
						showMsg(result.msg);
					}, 'json');
				}
			});
		} else {
			showMsg("请选择操作记录.");
		}
	}
	
	function clearlinkTimeSearch() {
		setGridSearchParams('linkage_time_list','linkeTimeSearchForm',true,reloadLinkageTime);
	}
	
	//根据条件查询
	function linkageTimeSearch() {
		setGridSearchParams('linkage_time_list','linkeTimeSearchForm',false,reloadLinkageTime);
	}
	
	function onClickLinkTime(rowIndex, rowData) {
		printLog(rowIndex);
		//先取得 datagrid 的查询参数  
		var params = $('#linkageAction_time_list').datagrid('options').queryParams;
		params['linkageId'] = rowData.id;
		//设置好查询参数 reload 一下就可以了 
		$('#linkageAction_time_list').datagrid('reload');  
	}
</script>


<div class="easyui-layout" data-options="fit:true">
	<div data-options="region: 'west', title: '定时联动列表',border:false, split: true," style="width: 580px;">
		<@eu.datagrid id="linkage_time_list" toolbar="#linkagelist_time_search" idField="id" 
			 url="linkage.do?loadList&action=timerLink" rownumbers="true" onClickRow="onClickLinkTime(rowIndex, rowData)"
			 item="com.xdtech.sh.vo.LinkageTimeItem"/>
		
		<div id="linkagelist_time_search">
			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;">
				<form id="linkeTimeSearchForm">
					<table>
						<tr>
							<td>所属项目：</td>
							<td>
							<@eu.comboBox url="shProject.do?loadProjectCombox&key=PROJECT_TYPE" name="projectId" onSelect="linkActionByProCombox('linkTimeBuildId','linkTimeUnitId','linkTimeHouseId',null,value)"/>
							</td>
							<td class="tbLabel">所属楼栋:</td>
							<td>
								<@eu.comboBox id="linkTimeBuildId" url="building.do?loadBuildingCombox" name="buildingId" onSelect="linkActionByBuildCombox('linkTimeUnitId','linkTimeHouseId',null,value)"/>
							</td>
							
						</tr>
						<tr>
							<td class="tbLabel">所属单元:</td>
							<td>
								<@eu.comboBox id="linkTimeUnitId" url="unit.do?loadUnitCombox" name="unitId" onSelect="linkActionByUnitCombox('linkTimeHouseId',null,value)"/>
							</td>
							<td class="tbLabel">所属房屋:</td>
							<td>
								<@eu.comboBox id="linkTimeHouseId" url="house.do?loadHouseCombox" name="houseId" />
							</td>
						</tr>
						<tr>
							<td colspan="2">
								<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="linkageTimeSearch()"/>
	 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearlinkTimeSearch()"/>
 					 		</td>
						</tr>
					</table>
				</form>
				
			</div>
			<div id="linkTime_toolbar" style="height: auto">
				<@eu.linkbutton showName="刷新" shiro="sh:linkage:refresh" iconCls="icon-reload" onclick="reloadLinkageTime()"/>	
				
			</div>
		</div>
	</div>
	<div data-options="region:'center',border:false">
		<@eu.datagrid id="linkageAction_time_list" idField="id"
			 url="linkageAction.do?loadList" rownumbers="true"
			 item="com.xdtech.sh.vo.LinkageActionItem"/>
	</div>
</div>